﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Eventbrite;
using System.Diagnostics;
using System.Threading.Tasks;

namespace EventbriteExample
{
    public partial class MainPage : PhoneApplicationPage
    {
        EventbriteClient eventbrite;

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            if (string.IsNullOrEmpty(AppKeys.kEventbriteAppKey))
                throw new NotImplementedException("You need to add your keys");
            eventbrite = new EventbriteClient(AppKeys.kEventbriteAppKey);
        }
        private void clickMeButton_Click(object sender, RoutedEventArgs e)
        {
            Auth();
        }
        private async Task Auth()
        {
            var result = await eventbrite.AuthorizeAsync("http://jaykimble.net");
            Debug.WriteLine("authd: " + result);
            if (result)
            {
                runTests();
            }
        }

        private async Task runTests()
        {
            var userId = "2813326";
            var eventId = "3571098251";
            var userEmail = "jkimble@intradynamics.net";
            var result = await eventbrite.GetUser();
            Debug.WriteLine("\n!!!!!!!!!{0}: \n{1}", "GetUser", result);

            result = await eventbrite.ListUserEvents(userEmail, doNotDisplay: new[] { "description", "venue", "logo", "style", "organizer", "tickets" }, sortOrder: SortOrder.Desc);
            Debug.WriteLine("\n!!!!!!!!!{0}: \n{1}", "ListUserEvents", result);

            result = await eventbrite.ListUserTickets();
            Debug.WriteLine("\n!!!!!!!!!{0}: \n{1}", "ListUserTickets", result);

            result = await eventbrite.ListOrganizersForUser();
            Debug.WriteLine("\n!!!!!!!!!{0}: \n{1}", "ListUserOrganizers", result);

        }
    }
}